package com.ebs.magicapidemo.generator;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;

import java.util.Collections;

/**
 * Mybatis Plus 代码生成器
 */
public class MyBatisPlusCodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://www.yugaosu.com:33306/magic_api?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&TimeZone=Asia/Shanghai&serverTimezone=GMT", "root", "jingguan+705")
                .globalConfig(builder -> {
                    builder
                            // 设置作者
                            .author("Alexander Chang")
                            // 开启swagger模式
                            .enableSwagger()
                            // 覆盖已生成文件
                            //.fileOverride()
                            // 指定输出目录
                            .outputDir("d://mybatis_generator/");
                })
                .packageConfig(builder -> {
                    builder
                            // 设置父包名
                            .parent("com.ebs.magicapidemo")
                            // 设置父包模块名
                            //.moduleName("system")
                            // 设置mapperXml生成路径
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "d://mybatis_generator/"));
                })
                .strategyConfig(builder -> {
                    builder
                            .addInclude("ship")
                            .addInclude("user");
                })
                // 设置模板
                .templateEngine(new VelocityTemplateEngine())
                .execute();
    }
}
